home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / intuition / printitext.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  3KB  |  126 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: printitext.c,v 1.3 1996/08/29 15:13:32 digulla Exp $
  4.     $Log: printitext.c,v $
  5.     Revision 1.3  1996/08/29 15:13:32  digulla
  6.     Wrote code
  7.  
  8.     Revision 1.2  1996/08/29 13:57:37  digulla
  9.     Commented
  10.     Moved common code from driver to Intuition
  11.  
  12.     Revision 1.1  1996/08/23 17:28:18  digulla
  13.     Several new functions; some still empty.
  14.  
  15.  
  16.     Desc:
  17.     Lang: english
  18. */
  19. #include "intuition_intern.h"
  20. #include <string.h>
  21. #include <clib/graphics_protos.h>
  22.  
  23. /*****************************************************************************
  24.  
  25.     NAME */
  26.     #include <graphics/rastport.h>
  27.     #include <intuition/intuition.h>
  28.     #include <clib/intuition_protos.h>
  29.  
  30.     __AROS_LH4(void, PrintIText,
  31.  
  32. /*  SYNOPSIS */
  33.     __AROS_LHA(struct RastPort  *, rp, A0),
  34.     __AROS_LHA(struct IntuiText *, iText, A1),
  35.     __AROS_LHA(long              , leftOffset, D0),
  36.     __AROS_LHA(long              , topOffset, D1),
  37.  
  38. /*  LOCATION */
  39.     struct IntuitionBase *, IntuitionBase, 36, Intuition)
  40.  
  41. /*  FUNCTION
  42.     Render an IntuiText in the specified RastPort with the
  43.     specified offset.
  44.  
  45.     INPUTS
  46.     rp - Draw into this RastPort
  47.     iText - Render this text
  48.     leftOffset, topOffset - Starting-Point. All coordinates in the
  49.         IntuiText structures are relative to this point.
  50.  
  51.     RESULT
  52.     None.
  53.  
  54.     NOTES
  55.  
  56.     EXAMPLE
  57.  
  58.     BUGS
  59.  
  60.     SEE ALSO
  61.  
  62.     INTERNALS
  63.  
  64.     HISTORY
  65.     29-10-95    digulla automatically created from
  66.                 intuition_lib.fd and clib/intuition_protos.h
  67.  
  68. *****************************************************************************/
  69. {
  70.     __AROS_FUNC_INIT
  71.     __AROS_BASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  72.     ULONG  apen;
  73.     ULONG  bpen;
  74.     ULONG  drmd;
  75.     struct TextFont * font;
  76.     struct TextFont * newfont;
  77.  
  78.     /* Store important variables of the RastPort */
  79.     apen = GetAPen (rp);
  80.     bpen = GetBPen (rp);
  81.     drmd = GetDrMd (rp);
  82.  
  83.     font = rp->Font;
  84.  
  85.     /* For all borders... */
  86.     for ( ; iText; iText=iText->NextText)
  87.     {
  88.     /* Change RastPort to the colors/mode specified */
  89.     SetAPen (rp, iText->FrontPen);
  90.     SetBPen (rp, iText->BackPen);
  91.     SetDrMd (rp, iText->DrawMode);
  92.  
  93.     if (iText->ITextFont)
  94.     {
  95.         newfont = OpenFont (iText->ITextFont);
  96.  
  97.         if (newfont)
  98.         SetFont (rp, newfont);
  99.     }
  100.  
  101.     /* Move to initial position */
  102.     Move (rp
  103.         , iText->LeftEdge + leftOffset
  104.         , iText->TopEdge + topOffset
  105.     );
  106.     Text (rp, iText->IText, strlen (iText->IText));
  107.  
  108.     if (iText->ITextFont)
  109.     {
  110.         if (newfont)
  111.         {
  112.         SetFont (rp, newfont);
  113.         CloseFont (newfont);
  114.         }
  115.     }
  116.     }
  117.  
  118.     /* Restore RastPort */
  119.     SetAPen (rp, apen);
  120.     SetBPen (rp, bpen);
  121.     SetDrMd (rp, drmd);
  122.     SetFont (rp, font);
  123.  
  124.     __AROS_FUNC_EXIT
  125. } /* PrintIText */
  126.